package com.osfw.framework.config;

import freemarker.template.Configuration;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * freemarker 配置
 */
@Component
public class FreemarkerConfig {

    @Autowired
    private Configuration configuration;

    /**
     * Shiro整合Freemarker模板标签，自定义字典、配置等标签
     * @throws TemplateModelException
     */
    @PostConstruct
    public void setSharedVariable() throws TemplateModelException, IOException {
        // Shiro整合Freemarker模板标签
        // configuration.setSharedVariable("shiro", new ShiroTags());

        // 添加自己的要传输到页面的[方法、对象、值]
        // configuration.setSharedVariable("dict", new DictDirective());
        // configuration.setSharedVariable("config", new ConfigDirective());

        //防止页面输出数字,变成2,000
        configuration.setNumberFormat("#");
    }

}
